package run.bottle.shiro.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
public class SwaggerConfig {
    /**
     * 配置Docket Bean实例
     * @return
     */
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true)//是否启动swagger
                .groupName("Bottle Api")
                .select()
                .apis(RequestHandlerSelectors.basePackage("run.bottle.shiro.controller"))
                .build();
    }

    //配置Swagger信息
    private ApiInfo apiInfo() {

        // 作者信息
        Contact contact = new Contact("bottle", "http://www.bottle.run", "38707145@qq.com");

        return new ApiInfo("Bottle Swagger Api文档",
                "努力奔向更美好的你",
                "1.0",
                "http://www.bottle.run",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
